#coding:utf8
import random
from  nltk.corpus import movie_reviews
from nltk.corpus import stopwords
from nltk import FreqDist
from nltk import NaiveBayesClassifier
from nltk.classify import accuracy
import string


sw=set(stopwords.words('english'))
punctuation=set(string.punctuation)  #去除标点符号
def isStopWord(word):  #判断是否是停用词
    return word in sw or word in punctuation
review_words=movie_reviews.words()
filtered=[w.lower() for w in review_words if not isStopWord(w.lower())]
#print filtered

words=FreqDist(filtered)  #词频统计
N=int(0.01*len(words.keys()))
tags=words.keys()[:N]

for tag in tags:
    print(tag,":",words[tag])